#!/usr/bin/env python3
# -*-coding: utf-8-*-

def fact(n):

    '''
    calculate 1*2*3...*n
    
    >>> fact(1)
    1
    >>> fact(3)
    6
    >>> fact(-1)
    Traceback (most recent call last):
        File "D:\Python36\lib\doctest.py", line 1330, in __run
        compileflags, 1), test.globs)
        File "<doctest __main__.fact[2]>", line 1, in <module>
        fact(-1)
        File "doctest20190426.py", line 17, in fact
        raise ValueError()
    ValueError
    '''
    if n < 1:
        raise ValueError()
    if n == 1:
        return 1
    return n * fact(n-1)

if __name__ == '__main__':
    import doctest
    doctest.testmod()
